PREFIX         =./lib
LIBNAME        =myserver
APP_NAME       =server

SQLITE_LIB     =./sqlite3/lib
SQLITE_INC     =./sqlite3/include

CFLAGS         += -I ./inc/ -I${SQLITE_INC}
LDFLAGS        += -L${PREFIX} -l${LIBNAME} -L${SQLITE_LIB} -lsqlite3

SRC_MAIN       =./src/main.c
SRC_LIB        =./src/server.c ./src/database.c 

all:static_lib run 

run:
	gcc ${CFLAGS} ${SRC_MAIN} -o ${APP_NAME} ${LDFLAGS}

static_lib:
	mkdir -p ${PREFIX}
	gcc ${CFLAGS} -c ${SRC_LIB}
	ar -rcs lib${LIBNAME}.a *.o
	mv lib${LIBNAME}.a ${PREFIX}

clean:distclean
	rm -f ${APP_NAME} *.db
	rm -f ${PREFIX}/lib${LIBNAME}.a 
distclean:
	rm -f *.o
